<{capture name="header"}>
<{lang_script src="lang.js" app='b2c'}>
<{script src="goodseditor.js" app="b2c"}>
<{script src="coms/pager.js" app='desktop'}>
<{script src="coms/datapicker.js"  app='desktop'}>

<{/capture}>
<script>
  function selecttype(input){


        var updatebrand=$('updatebrand');
         //if(request)request.cancel();

        var request = new Request.HTML({
                   
                    url:'<{link app="business" ctl="admin_storemanger" act="changebrand" }>',
                    update:updatebrand,
                    onComplete:function(res){
                        updatebrand.show();
                    }                                        
         }).post($H({selectvaue:input}));


        //2013-6-17  平台管理可开放授权店铺多类目经营
        /*
        var update=$('updateregion');
         //if(request)request.cancel();

        var request = new Request.HTML({
                   
                    url:'<{link app="business" ctl="admin_storemanger" act="changeregion" }>',
                    update:update,
                    onComplete:function(res){
                        
                      
                        update.show();
                    }                                        
         }).post($H({selectvaue:input}));
        */

        var  updatename=$('issue_type_name');
        var request = new Request.HTML({
                   
                    url:'<{link app="business" ctl="admin_storemanger" act="updateissuename" }>',
                    update:updatename,
                    onComplete:function(res){
                        updatename.show();
                    }                                        
         }).post($H({selectvaue:input}));

       






  }
   function nameCheck(input){
     
         new Request.JSON({
            url:'<{link app=business ctl=admin_storemanger act=getmemberidbyloginname}>',
            method:'post',
            data:'name='+encodeURIComponent(input.value=input.value.trim()),
            async:false,
            onComplete:function(re){
                if(re != null ) {
                    if(re.result =='true'){
                        $('newshopid-edit-form-GId-input').value = re.msg;
                    } else {
                        if('<{$shopinfo.account_id}>' !=re.account_id){
                          //MessageBox.error(re.msg);
                          //Ex_Dialog.alert(re.msg);
                          alert( re.msg);
                          $('shopername').value ='';
                          $('newshopid-edit-form-GId-input').value='';
                          return;
                        }
                    }
                } else {
                    
                  alert('<{t}>该会员不存在，请重新输入。<{/t}>');
                  $('shopername').value ='';
                  return;
                }

            }
        }).send();

    }

    //验证电话号码
    var isPhone=function (str) {
        
       //var reg =/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}|14[0-9]{1}[0-9]{8}$/;
       var reg =/^(0\d{2,3}-)[23456789]\d{6,7}?$/;
       return reg.test(str);
    }

    function checkphonenum(input){
       if(input.value!='' &&  !isPhone(input.value)){
           MessageBox.error('号码格式错误！');
           //input.value='';
           return false;
       }
       return true;
    }

  

    /* ***********************************************************************/
//var goodsEditor = null;

var goodsEditFrame = (function(){

    //goodsEditor = new csbbcGoodsEditor('gEditor',{imgtype:'<{$uploader}>',url:'<{$url}>',store_id:'<{$shopinfo.shop_id}>'});

    /******************************************/
        /*
         *  sign:{
               1:保存并增加相似商品,
               2:保存并返回,
               3:保存当前不返回，
         *    }
         */
   var _form=$('gEditor'),_formActionURL=_form.get('action');

   subShopinfoForm = function (event,sign){
        var _default_disabled_bn = false;
       $$('.class-bn').each(function(item,index){
          if($(item).get('disabled')) {
            _default_disabled_bn = true;
            $(item).set('disabled', false);
          }
       });



    switch (sign){
            case 1:
            
            var target={
                    onComplete:function(){
                        location.reload();
                         if( _default_disabled_bn ) {
                          $$('.class-bn').set('disabled', true);
                        }
                       
                }};
            break;
            case 2:
            var target={
                    onComplete:function(rs){
                        if(JSON.decode(rs).error) {
                            return ;
                        }
                        if(window.opener.finderGroup&&window.opener.finderGroup['<{$env.get.finder_id}>']){
                            window.opener.finderGroup['<{$env.get.finder_id}>'].refresh();
                        }
                        window.close();
                        if( _default_disabled_bn ) {
                          $$('.class-bn').set('disabled', true);
                        }

                    }};
            break;
            case 3:
            var target={           //保存当前
                    onComplete:function(rs){
                        var id = JSON.decode(rs).store_id;
                        if(id > 0){
                            $('newshopinfo-edit-form-GId-input').value =id;
                            $('gEditor-g-type').value ='edit';
                            if( _default_disabled_bn ) {
                            $$('.class-bn').set('disabled', true);
                                }
                          
                        }
                      
                    }};
            break;
       }

       if(checkphonenum($('company_ctel'))) {
           _form.store('target',target);
           _form.fireEvent('submit',new Event(event));
       }

   };
});

goodsEditFrame();

</script>
<style type="text/css">
    .iw_poi_title {color:#CC5522;font-size:14px;font-weight:bold;overflow:hidden;padding-right:13px;white-space:nowrap}
    .iw_poi_content {font:12px arial,sans-serif;overflow:visible;padding-top:4px;white-space:-moz-pre-wrap;word-wrap:break-word}
</style>
<form name="gEditor" id="gEditor" method='post'  action="index.php?app=business&ctl=admin_storemanger&act=toAdd">
<input name="__type" value="<{$shopinfo.store_id ? 'edit' : 'add'}>" id="gEditor-g-type" type="hidden">
<div class="tableform">
    <div class="division">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr><th style="width:10%;"><em class="red">*</em><{t}>店主名：<{/t}></th>
        <input  name="shopinfo[store_id]" value="<{$shopinfo.store_id}>" id="newshopinfo-edit-form-GId-input" type="hidden" value=$shopinfo.store_id>
        <input name="shopinfo[account_id]" value="<{$shopinfo.account_id}>" id="newshopid-edit-form-GId-input" type="hidden" value=$shopinfo.account_id>

        <td>
        <{if $shopinfo.account_id}>
       	<{input  readonly='true' type="text" id="shopername" name="shopinfo[shop_name]"  vtype="required"  value=$shopinfo.shop_name }> 
        <{else}>
        <{input  type="text" id="shopername" name="shopinfo[shop_name]"  vtype="required" autocompleter="b2c_autocomplete_member:login_name,member_id" ac_options="{relative:false}" value=$shopinfo.shop_name onblur="nameCheck(this);"}> 
        <{/if}>
        &nbsp; <{help}><{t}>此处填写前台会员用户名。<{/t}><{/help}>
        </td>
        </tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>店主实名：<{/t}></th>
        <td><{input type="text" maxlength=10 name="shopinfo[store_idcardname]" id="store_idcardname"  size="20" vtype="required" value=$shopinfo.store_idcardname}>
         &nbsp; <{help}><{t}>此处填写身份证上姓名。<{/t}><{/help}>
        </td>
        </tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>身份证号：<{/t}></th>
        <td><{input type="alphaint"  maxlength=18 name="shopinfo[store_idcard]" id="store_idcard"  size="20" vtype="required" value=$shopinfo.store_idcard}></td></tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>店铺名称：<{/t}></th>
        <td><{input type="text" maxlength=30 name="shopinfo[store_name]" id="store_name"  size="20" vtype="required" value=$shopinfo.store_name}></td></tr>

        <tr style='display:none'><th style="width:10%;"><em class="red">*</em><{t}>所属分类：<{/t}></th>
        <td>
        <{input type="storecat" value=$shopinfo.store_cat name="shopinfo[store_cat]"}>
        </td>
         </tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>所属等级：<{/t}></th>
        <td>
        <{input type="select" id='storetype' name="shopinfo[store_grade]" options=$storegrade value=$shopinfo.store_grade  vtype="required"  onchange="selecttype(this.value);" }>
        <div style='float:right;color:red;width:50%;' id='issue_type_name'>
         <{if $shopinfo}>
              <{if $shopinfo.issue_type ==0}>
              <{t}>卖场型旗舰店<{/t}>
              <{elseif $shopinfo.issue_type ==1}>
              <{t}>专卖店<{/t}>
              <{elseif $shopinfo.issue_type ==2}>
              <{t}>专营店<{/t}>
               <{elseif $shopinfo.issue_type ==3}>
              <{t}>品牌旗舰店<{/t}>
              <{/if}>
         <{/if}>
        </div>
        </td>
        </tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>经营范围：<{/t}></th>
        <td>
        <div id='updateregion'>
        <{input type="object" vtype="required" object="goods_cat@b2c" filter=$storetype value=$shopinfo.store_region  name="shopinfo[store_region]"  multiple="true" select="checkbox" view="business:admin/store/storegrade_items.html"}> &nbsp;
        </div>
        </td></tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>所在地区：<{/t}></th>
        <td><{input app=ectools id="area" type="region"  name="shopinfo[area]" vtype='area' value=$shopinfo.area}></td></tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>详细地址：<{/t}></th>
        <td><{input type="text" id=addr maxlength=200  name="shopinfo[addr]" size="60" vtype="required"   value=$shopinfo.addr}></td></tr>
       
        <tr><th style="width:10%;"><em class="red">*</em><{t}>手机号码:<{/t}></th>
        <td><{if $shopinfo.tel}>
        <{input readonly='true' type='text' vtype="required&&mobile" id=tel name="shopinfo[tel]" value=$shopinfo.tel}>
        <{else}>
        <{input  type='text' vtype="required&&mobile" id=tel name="shopinfo[tel]" value=$shopinfo.tel}>
        <{/if}>
        &nbsp; <{help}><{t}>此处与会员信息中同步，请谨慎修改。<{/t}><{/help}>
        </td></tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>邮箱：<{/t}></th>
        <td>
        <{if $shopinfo.zip}>
        <{input readonly='true' type="text" id=zip name="shopinfo[zip]" size="20" maxlength=20  vtype='required&&email' value=$shopinfo.zip}>
        <{else}>
        <{input type="text" id=zip name="shopinfo[zip]" size="20" maxlength=20  vtype='required&&email' value=$shopinfo.zip}>
        <{/if}>
         &nbsp; <{help}><{t}>此处与会员信息中同步，请谨慎修改。<{/t}><{/help}>
        </td></tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>密保问题：<{/t}></th>
        <td>
        
        <{input  type='text'  id=pw_question maxlength='50' name="shopinfo[pw_question]" value=$shopinfo.pw_question cols=50   vtype="required"}>
       
         &nbsp; <{help}><{t}>此处与会员信息中同步，请谨慎修改。<{/t}><{/help}>
        </td></tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>密保答案：<{/t}></th>
        <td>
      
        <{input  type='text'  id=pw_answer maxlength='50' name="shopinfo[pw_answer]" value=$shopinfo.pw_answer cols=50   vtype="required"}>
        
         &nbsp; <{help}><{t}>此处与会员信息中同步，请谨慎修改。<{/t}><{/help}>
        </td></tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>有效期：<{/t}></th>
        <td><{input type="date" id=last_time name="shopinfo[last_time]" size="6"  value=$shopinfo.last_time}></td></tr>

        <tr><th style="width:10%;"><{t}>保证金：<{/t}></th>
        <td><{input type="money" id=earnest name="shopinfo[earnest]" size="12"  value=$shopinfo.earnest vtype="number"}></td></tr>

        <tr><th style="width:10%;"><{t}>开启状态：<{/t}></th>
        <td><{input type="intbool" id=status name="shopinfo[status]" size="6"  value=$shopinfo.status}></td></tr>

<!--
        <tr><th style="width:10%;display:none;"><{t}>认证：<{/t}></th>
            <td style="display:none;">
            <label><input type="checkbox" name="shopinfo[certification][uname]"  <{if $shopinfo.certification.uname=='on'}>checked<{/if}>><{t}>实名认证<{/t}></label>
            <label><input type="checkbox" name="shopinfo[certification][ushop]"  <{if $shopinfo.certification.ushop=='on'}>checked<{/if}>><{t}>实体店铺认证<{/t}></label>
            </td>
        </tr>

  -->


        <tr><th style="width:10%;"><{t}>推荐状态：<{/t}></th>
        <td ><{input type="intbool" id=recommend name="shopinfo[recommend]" size="6"  value=$shopinfo.recommend}></td></tr>

        <tr><th style="width:10%;"><{t}>审核状态：<{/t}></th>
        <td>
          <{if $shopinfo.approved ==1}>
          <{t}>审核通过<{/t}>
          <{elseif $shopinfo.approved ==2}>
          <{t}>审核未通过<{/t}>
          <{else}>
          <{t}>待审核<{/t}>
          <{/if}>
        </td></tr>
        <tr><th style="width:10%;"><{t}>审核备注：<{/t}></th>
        <td> <{input  type='text' disabled='true' id=approvedremark  name="shopinfo[approvedremark]" value=$shopinfo.approvedremark size="60"}></td></tr>


        <tr><th style="width:10%;"><{t}>主要品牌：<{/t}></th>
        <td>
        <div id='updatebrand'>
        <{if $shopinfo.issue_type==1 or $shopinfo.issue_type==3}>
            <{input type="object"  object="brand@b2c" value=$shopinfo.brand_id name="shopinfo[brand_id]" filter="disabled=false"  view="business:admin/store/brand_items.html"}> &nbsp;
        <{else}>
            <{input type="object"  object="brand@b2c" value=$shopinfo.brand_id name="shopinfo[brand_id]" textcol="name" cols="name" filter="disabled=false"  multiple="true" select="checkbox" view="business:admin/store/brand_items.html"}> &nbsp;
        <{/if}>

        </div>
        </td></tr>

        <tr style="display:none;"><th style="width:10%;"><{t}>主要店员：<{/t}></th>
        <td>
         <{help}><{t}>注：店员不可同时为多个店铺,也不可同时为店主。<{/t}><{/help}>
        <{input type="object"  object="members@b2c" value=$shopinfo.member_id name="shopinfo[member_id]" textcol="name" cols="name" filter="disabled=false" multiple="true" select="checkbox" view="business:admin/store/member_items.html"}> &nbsp;
        </td></tr>
        <tr><th style="width:10%;"><{t}>店铺备注：<{/t}></th>
        <td> <{input  type='text' id=remark  name="shopinfo[remark]" value=$shopinfo.remark size="60"}></td></tr>
        </table>
    </div>

    <div class="division" >
       <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr><th style="width:10%;"><em class="red">*</em><{t}>企业名称：<{/t}></th>
        <td><{input type="text" maxlength=30 name="shopinfo[company_name]" id="company_name"  size="20" vtype="required" value=$shopinfo.company_name}>
         &nbsp; <{help}><{t}>此处填写营业执照上企业名称。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>营业执照号：<{/t}></th>
        <td><{input type="alphaint"  maxlength=15  name="shopinfo[company_no]" id="company_no"  size="20" vtype="required" value=$shopinfo.company_no}>
         &nbsp; <{help}><{t}>此处填写营业执照号。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>税务登记证号：<{/t}></th>
        <td><{input type="alphaint" maxlength=15 name="shopinfo[company_taxno]" id="company_taxno"  size="20" vtype="required" value=$shopinfo.company_taxno}>
         &nbsp; <{help}><{t}>此处填写税务登记证号。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>企业组织机构代码：<{/t}></th>
        <td><{input type="alphaint" maxlength=15 name="shopinfo[company_codename]" id="company_codename"  size="20" vtype="required" value=$shopinfo.company_codename}>
         &nbsp; <{help}><{t}>此处填写企业组织机构代码。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>法定代表人：<{/t}></th>
        <td><{input type="text"  maxlength=10 name="shopinfo[company_idname]" id="company_idname"  size="20" vtype="required" value=$shopinfo.company_idname}>
         &nbsp; <{help}><{t}>此处填写法定代表人姓名。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>法人身份证号：<{/t}></th>
        <td><{input type="alphaint" maxlength=18 name="shopinfo[company_idcard]" id="company_idcard"  size="20" vtype="required" value=$shopinfo.company_idcard}>
        &nbsp; <{help}><{t}>此处填写法人身份证号。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>公司负责人姓名：<{/t}></th>
        <td><{input type="text" maxlength=10 name="shopinfo[company_cname]" id="company_cname"  size="20" vtype="required" value=$shopinfo.company_cname}>
         &nbsp; <{help}><{t}>此处填写公司负责人(申请人)姓名。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>负责人身份证号：<{/t}></th>
        <td><{input type="alphaint" maxlength=18  name="shopinfo[company_cidcard]" id="company_cidcard"  size="20" vtype="required" value=$shopinfo.company_cidcard}>
        &nbsp; <{help}><{t}>此处填写公司负责人(申请人)身份证号。<{/t}><{/help}>
        </td>
        </tr>
        
        <tr><th style="width:10%;"><em class="red">*</em><{t}>负责人职务：<{/t}></th>
        <td><{input type="text" maxlength=20 name="shopinfo[company_charge]" id="company_charge"  size="20" vtype="required" value=$shopinfo.company_charge}>
         &nbsp; <{help}><{t}>此处填写公司负责人(申请人)职务。<{/t}><{/help}>
        </td>
        </tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>企业联系电话：<{/t}></th>
        <td> <{input  type="alphaint" maxlength=13  vtype="required" id=company_ctel name="shopinfo[company_ctel]" value=$shopinfo.company_ctel onblur='checkphonenum(this);'}>
         &nbsp; <{help}><{t}>此处填写企业联系电话，格式：0755-22222222。<{/t}><{/help}>
        </td></tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>公司注册地区：<{/t}></th>
        <td><{input app=ectools id="company_area" type="region" maxlength=200  name="shopinfo[company_area]" vtype='area' value=$shopinfo.company_area}></td></tr>
        <tr><th style="width:10%;"><em class="red">*</em><{t}>注册地址：<{/t}></th>
        <td><{input type="text" id=company_addr name="shopinfo[company_addr]" size="60" vtype="required"   value=$shopinfo.company_addr}></td></tr>
      
        <tr><th style="width:10%;"><em class="red">*</em><{t}>注册资金：<{/t}></th>
        <td><{input type="number" maxlength=10 id=company_earnest name="shopinfo[company_earnest]" size="12"  value=$shopinfo.company_earnest vtype="required&&unsigned"}><{t}>万元<{/t}></td></tr>
        
        <tr><th style="width:10%;"><em class="red">*</em><{t}>公司成立时间：<{/t}></th>
        <td><{input type="date" id=company_time name="shopinfo[company_time]" size="6"  value=$shopinfo.company_time vtype="required"}></td></tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>营业执照有效期：<{/t}></th>
        <td><{input type="date" id=company_timestart name="shopinfo[company_timestart]" size="6"  value=$shopinfo.company_timestart vtype="required"}>
        &nbsp;&nbsp;~&nbsp;&nbsp;
        <{input type="date" id=company_timeend name="shopinfo[company_timeend]" size="6"  value=$shopinfo.company_timeend vtype="required"}>
        </td></tr>

        <tr><th style="width:10%;"><{t}>公司官网地址：<{/t}></th>
        <td> <{input  type='text' id=company_url  vtype="url"  name="shopinfo[company_url]" value=$shopinfo.company_url size="60"  }></td></tr>

        <tr><th style="width:10%;"><em class="red">*</em><{t}>营业执照经营范围：<{/t}></th>
        <td> <{input  type='textarea' id=company_remark  name="shopinfo[company_remark]" value=$shopinfo.company_remark cols=50  vtype="required"}></td></tr>
     </table>
    </div>
        <div class="division" style="height:900px;">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <th style="width:10%;"><{t}>店铺图片：<{/t}></th>
                 <td>
                      <{input type='image' name='shopinfo[image]' width=200 height=150 value=$shopinfo.image}>
                  </td>

                </tr>

                <tr>
                 <th style="width:10%;"><{t}>店主证件：<{/t}></th>
                 <td>
                      <{input type='image' name='shopinfo[image_id]' width=200 height=150 value=$shopinfo.image_id}>
                  </td>

                </tr>

                 <tr>
                 <th style="width:10%;"><{t}>营业执照：<{/t}></th>
                 <td>
                      <{input type='image' name='shopinfo[image_cid]' width=200 height=150 value=$shopinfo.image_cid}>
                  </td>

                </tr>

                 <tr>
                 <th style="width:10%;"><{t}>组织机构代码：<{/t}></th>
                 <td>
                      <{input type='image' name='shopinfo[image_codeid]' width=200 height=150 value=$shopinfo.image_codeid}>
                  </td>

                </tr>

                  <tr>
                 <th style="width:10%;"><{t}>税务登记证：<{/t}></th>
                 <td>
                      <{input type='image' name='shopinfo[image_taxid]' width=200 height=150 value=$shopinfo.image_taxid}>
                  </td>

                </tr>

            </table>
      </div>


</div>
<{capture name="footbar"}>
<table cellspacing="0" cellpadding="0" class="table-action">
      <tbody>
        <tr valign="middle">
        <td>
            <{button label=$___b2c="保存并关闭窗口"|t:'b2c' class="btn-primary" onclick="subShopinfoForm(event,2)"}>
            <{if !$shopinfo.store_id}>
            <{button label=$___b2c="保存并添加相似店铺"|t:'b2c' class="btn-primary" onclick="subShopinfoForm(event,1)"}>
            <{/if}>
            <{button label=$___b2c="保存当前"|t:'b2c' class="btn-primary" onclick="subShopinfoForm(event,3)"}>
            <{assign var=bcclose value=$___b2c='确定退出?'|t:'b2c'}>
            <{assign var=bclose value="关  闭"}>
            <{button label=$___b2c=$bclose|t:'b2c' class="btn-secondary" onclick="if(confirm('{$bcclose}'))window.close()"}>
        </td>
        </tr>
        </tbody>
</table>
<{/capture}>
</form>









